const app = getApp()
const ClientApi = app.ClientApi
const clientGet = app.clientGet
import store from '../../utils/store'

Component({
    properties: {
    },
    data: {
        car: {},
        orderDetail: {}
    },
    methods: {
        async getCarInfo() {
            const factoryId = store.getItem("factoryId")
            const laneId = store.getItem('laneId')
            const carInfo = await clientGet(`${ClientApi.getCar}/factoryId/${factoryId}/laneId/${laneId}`)
            this.setData({car: carInfo})
            this.triggerEvent('getCarData', carInfo)
        },
        async getOrder() {
            const factoryId = store.getItem("factoryId")
            const laneId = store.getItem('laneId')
            const orderData = await clientGet(`${ClientApi.getOrderByLaneId}/factoryId/${factoryId}/laneId/${laneId}`)
            this.setData({
                orderDetail: orderData
            })
        },
    },
    lifetimes: {
        async attached() {
            this.triggerEvent('activeChange', 2)
            await this.getCarInfo()
            await this.getOrder()
        }
    }
});
